package com.ddbook.controller;

import com.ddbook.mapper.AuthorMapper;
import com.ddbook.model.Author;
import com.ddbook.result.Result;
import com.ddbook.result.ResultConstant;
import com.ddbook.service.AuthorService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootTest
@RestController
@RequestMapping("register")
public class RegisterController {

    @Autowired
    private AuthorMapper authorMapper;

    @Autowired
    private AuthorService authorService;

    @Test
    public void Register(){
        Author author = new Author();
        author.setName("张三");
        authorMapper.insert(author);
    }

    @PostMapping("register")
    public Result register(Author author){
        authorService.register(author);
        return new Result(ResultConstant.REGISTER_SUCCESS_CODE,ResultConstant.REGISTER_SUCCESS_DATA);
    }

}
